﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Diagnostics;


public partial class OutSourcingGeografia : System.Web.UI.Page
{
    //creamos el dataset que contendra las tablas
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["iduser"] == null || Session["iduser"].ToString() == "0")
            {
                Response.Redirect("index.aspx");
            }
            else
            {
                //llenamos el dataset con los datos de la tablas de Outsourcing
                Outs.Outsourcing G = new Outs.Outsourcing();
                ds = G.ConsultaOutSourcing();
            }
        }
 
    }
      
    
    
protected void  ImageButton1_Click1(object sender, ImageClickEventArgs e)
{
    try
    {
        //creamos el objeto tabla para llenar una nueva fila
        DataTable TOut = ds.Tables["Paises"];
        DataRow row = TOut.NewRow();
        //ingrasamos los datos de la fila
        row["IdPais"] = ds.Tables["Paises"].Rows.Count + 1;
        row["Nombre"] = txtOutPais.Text;
        row["IdOutsourcing"] = 1;

        ds.Tables["Paises"].Rows.Add(row);

        Outs.Outsourcing cl = new Outs.Outsourcing();
        cl.DatoPais(ds);
        ds.AcceptChanges();
    }
    catch (Exception ex)
    {


        EventLog LogErr = new EventLog();
        if (!EventLog.SourceExists("WebContrataci"))
        {
            EventLog.CreateEventSource("WebContrataci", "Application");
            LogErr.Source = "WebContrataci";
            LogErr.WriteEntry(ex.ToString(), EventLogEntryType.Information, 1);
        }
        else
        {

            LogErr.Source = "WebContrataci";
            LogErr.WriteEntry(ex.ToString());
        }
    }
}

protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
    try
    {
        //creamos el objeto tabla para llenar una nueva fila
        DataTable TOut = ds.Tables["TiposContrato"];
        DataRow row = TOut.NewRow();
        //ingrasamos los datos de la fila
        row["IdTiposContrato"] = ds.Tables["TiposContrato"].Rows.Count + 1;
        row["Nombre"] = TxtOutTipoContrato.Text;


        ds.Tables["TiposContrato"].Rows.Add(row);

        Outs.Outsourcing cl = new Outs.Outsourcing();
        cl.DatoTContrato(ds);
        ds.AcceptChanges();
    }
    catch (Exception ex)
    {


        EventLog LogErr = new EventLog();
        if (!EventLog.SourceExists("WebContrataci"))
        {
            EventLog.CreateEventSource("WebContrataci", "Application");
            LogErr.Source = "WebContrataci";
            LogErr.WriteEntry(ex.ToString(), EventLogEntryType.Information, 1);
        }
        else
        {

            LogErr.Source = "WebContrataci";
            LogErr.WriteEntry(ex.ToString());
        }
    }
}
}